<template>
	<div class="container" ref="refContainer">
		<div class="doc-content">
			<div class="title">
				Slide滑块
			</div>
			<div class="sub-title quote">
				
			</div>
			
			<div class="example-title">引入方式（按需）</div>
			<code-view>
				<template slot="code-js">{{ jsCode1 }}</template>
			</code-view>
			
			<div class="example-title">基本用法</div>
			<code-view>
				<template slot="code-html">{{ htmlCode2 }}</template>
				<template slot="code-js">{{ jsCode2 }}</template>
			</code-view>
			
			<div class="example-title">指定数值范围</div>
			<code-view>
				<template slot="code-html">{{ htmlCode3 }}</template>
			</code-view>
			
			<div class="example-title">指定步长</div>
			<code-view>
				<template slot="code-html">{{ htmlCode4 }}</template>
			</code-view>
			
			<div class="example-title">自定义样式</div>
			<code-view>
				<template slot="code-html">{{ htmlCode5 }}</template>
			</code-view>
			
			<div class="example-title">&lt;gr-stepper&gt;属性</div>
			<gr-table :width="800" :tableData="propertiesExplain" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="参数名称" width="90">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="参数说明" width="150">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="类型" width="70">
						{{rowData.type}}
					</gr-table-column>
					<gr-table-column label="可选值" width="70">
						{{rowData.optionValues}}
					</gr-table-column>
					<gr-table-column label="默认值" width="60">
						{{rowData.defaultValue}}
					</gr-table-column>
				</template>
			</gr-table>
			
			<div class="example-title">&lt;gr-stepper&gt;事件</div>
			<gr-table :width="800" :tableData="propertiesExplain2" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="事件名称" width="100">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="事件说明" width="150">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="事件回调参数" width="120">
						{{rowData.param}}
					</gr-table-column>
				</template>
			</gr-table>
			
			<div class="example-title">Slots(插槽)</div>
			<gr-table :width="800" :tableData="propertiesExplain3" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="名称" width="150">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="说明" width="150">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="参数" width="150">
						{{rowData.param}}
					</gr-table-column>
				</template>
			</gr-table>
		</div>
		<div class="demo-view">
			<div ref="refCellPhone" class="cellphone">
				<iframe src="demo.html#/sliderdemo" frameborder="0" width="100%" height="100%"></iframe>
			</div>
		</div>
	</div>
</template>

<script>
	import Demo from '../components/Demo.vue'
	import CodeView from '../components/CodeView.vue'
	export default {
		components: {
			Demo, CodeView
		},
		data() {
			return {
				jsCode1: `import Slider from 'gabriel-ui/es/slider'
Vue.use(Slider)`,
				htmlCode2: `<gr-slider v-model="num1" />`,
				jsCode2: `export default {
	data() {
		return {
			num1: 10
		}
	}
}`,
				htmlCode3: `<gr-slider v-model="num2" min="500" max="1000" />`,
				htmlCode4: `<gr-slider v-model="num3" stepSize="10" />`,
				htmlCode5: `<gr-slider v-model="num4" bgColor="#9c2900" @change="onChange">
	<template slot="button">
		<div class="my-btn">{{num4}}</div>
	</template>
</gr-slider>`,
				propertiesExplain: [
					{
						attrName: 'v-model',
						introduce: `绑定的value值`,
						type: 'Number',
						optionValues: '----',
						defaultValue: '----'
					},
					{
						attrName: 'min',
						introduce: `最小值`,
						type: 'Number',
						optionValues: '----',
						defaultValue: '0'
					},
					{
						attrName: 'max',
						introduce: `最大值`,
						type: 'Number',
						optionValues: '----',
						defaultValue: '100'
					},
					{
						attrName: 'step',
						introduce: `步长(正整数)`,
						type: 'Number',
						optionValues: '----',
						defaultValue: '1'
					},
					{
						attrName: 'bgColor',
						introduce: `自定义滑槽的背景色`,
						type: 'String',
						optionValues: '----',
						defaultValue: '#1989fa'
					}
				],
				propertiesExplain2: [
					{
						attrName: 'change',
						introduce: `进度条变化时触发`,
						param: '当前value值'
					}
				],
				propertiesExplain3: [
					{
						attrName: 'button',
						introduce: `自定义滑动按钮`,
						param: '----'
					}
				]
			}
		},
		mounted() {
			let ele = this.$refs.refCellPhone
			this.$refs.refContainer.addEventListener('scroll', (e)=> {
				ele.style.top = e.target.scrollTop + 'px';
			})
		},
		methods: {
			copy(value) {
				this.$util.copy(value)
				this.$toast.show('已复制')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.doc-content {
		width: 1000px;
		.icon-list {
			margin-top: 20px;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.icon-view {
				width: 15%;
				padding: 2px;
				margin-top: 25px;
				-webkit-user-select: none;
				text-align: center;
				font-size: 14px;
				color: #666;
			}
		}
	}
</style>
